<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Insert title here</title>
<script type="text/javascript" src="<%=basePath%>js/jquery-2.1.0.min.js"></script>

<script type="text/javascript" src="<%=basePath%>js/layer/layer.js"></script>
<script type="text/javascript" src="<%=basePath%>js/BaseUtile.js"></script>
<script type="text/javascript" src="<%=basePath%>js/index/foodManage.js"></script>

<link rel="stylesheet" href="<%=basePath%>css/layui/css/layui.css">
<script type="text/javascript" src="<%=basePath%>css/layui/layui.all.js"></script>


</head>


<body style="padding: 2%">
	<div>
		<div style="text-align: center;">
			<b style="font-size: 25px">菜品管理</b>
			<button class="layui-btn layui-btn-danger" id="createFoodButton">新增菜品</button>
		</div>
		<div class="layui-input-inline">
			<div style="float: left">
				<input id="inputSearchWords" class="layui-input" 
					placeholder="输入菜品名或拼音搜索" />
			</div>
			<div style="float: left">
				<button id="searchFoodButton" class="layui-btn layui-btn-fluid">搜索</button>
			</div>
		</div>
		<div>
			<table class="layui-table">
				<thead>
					<tr>
						<th>序号</th>
						<th>商品名称</th>
						<th>拼音码</th>
						<th>菜系</th>
						<th>单位</th>
						<th>生产价格</th>
						<th>零售价</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:set var="num" value="1" />
					<c:forEach var="list" items="${foodList}">
						<tr>
							<td><c:out value="${num}" /></td>
							<c:set var="num" value="${num+1}" />
							<td>${list.foodName}</td>
							<td>${list.pinyin}</td>
							<td>${list.classification.classificationName}</td>
							<td>${list.unit.unitName}</td>
							<td>${list.productPrice}</td>
							<td>${list.sellPrice}</td>
							<td><button class="layui-btn"
									onclick="editFood(${list.foodId})">编辑</button>
								<button class="layui-btn"
									onclick="deleteFood(${list.foodId},'${list.foodName}')">删除</button></td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
		<c:if test="${page.nextPage==0}">
			<c:set var="nextPage" value="${page.lastPage}"></c:set>
		</c:if>
		<c:if test="${page.nextPage!=0}">
			<c:set var="nextPage" value="${page.nextPage}"></c:set>
		</c:if>
		<div style="text-align: center;">
			<a
				href="<%=basePath %>food/searchFoodByPage?page=${page.firstPage}&searchWords=${searchWords}"><button
					class="layui-btn layui-btn-primary">首页</button></a> <a
				href="<%=basePath %>food/searchFoodByPage?page=${page.prePage}&searchWords=${searchWords}"><button
					class="layui-btn layui-btn-primary">上一页</button></a><a
				href="<%=basePath %>food/searchFoodByPage?page=${nextPage}&searchWords=${searchWords}"><button
					class="layui-btn layui-btn-primary">下一页</button></a><a
				href="<%=basePath %>food/searchFoodByPage?page=${page.lastPage}&searchWords=${searchWords}"><button
					class="layui-btn layui-btn-primary">尾页</button></a>
			|当前第${page.pageNum}页,共${page.pages}页
		</div>

	</div>


	<script type="text/javascript">
	

$("#searchFoodButton").on("click", function() {
	var url=SERVER_PRE_URL+"food/searchFoodByPage?searchWords="+$("#inputSearchWords").val();
	window.location.href=encodeURI(encodeURI(url));
	
	
});

</script>



</body>
</html>